const UglifyJsPlugin = require('uglifyjs-webpack-plugin')
const CompressionWebpackPlugin = require('compression-webpack-plugin')

module.exports = {
  publicPath: '/',
  pages: {
    index: {
      entry: 'src/main.js',
      title: '海港时空地理信息系统',
    }
  },
  devServer: {
    port: 8081
  },
  productionSourceMap: false,
  configureWebpack: (process.env.NODE_ENV === 'production') ? {
    plugins: [
      new UglifyJsPlugin({
        uglifyOptions: {
          output: {
            comments: false
          },
        }
      }),
      new CompressionWebpackPlugin({
        test: /\.(js|css|html|svg)$/,
        algorithm: 'gzip',
        threshold: 10240,
        minRatio: 0.8
      })
    ]
  } : {
    devtool: "eval-source-map",
  }
}